{{ if or (and .IsHome .Site.Params.displayMenuInHome) (and (not .IsHome) .Site.Params.enableMenu) }}
    <nav class="nav">
        <ul class="menu" id="menu">
            {{ if .Site.Params.activeInSection }}
                {{ .Scratch.Set "currentPage" (.Site.GetPage (printf `/%s` .Section)) }}
            {{ else }}
                {{ .Scratch.Set "currentPage" . }}
            {{ end }}
            {{ $currentPage := .Scratch.Get "currentPage" }}
            {{ range .Site.Menus.main }}
                <li class="menu-item{{ if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{ end }}">
                    {{- $linkType := (string .Pre) -}}
                    <a href="{{ .URL }}"{{ if eq $linkType "external" }} target="_blank" rel="external noopener"{{ end }}>
                        {{- $iconName := (string .Post) -}}
                        {{- $icon := (index $.Site.Data.SVG $iconName) -}}
                        {{- printf `%s` (replace $icon "icon" "icon menu-item-icon") | safeHTML -}}
                        {{- with .Name -}}
                            {{- printf `<span class="menu-item-name">%s</span>` . | safeHTML -}}
                        {{- end -}}
                    </a>
                </li>
            {{ end }}
        </ul>
    </nav>
{{ end }}